<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Ai聊天</title>
    <script src="js/jquery.min.js"></script>
    <meta name="description" content="Charcoal is a free Bootstrap 4 UI kit build by @attacomsian at Wired Dots." />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--Bootstrap 4-->
    <link rel="stylesheet" href="css/bootstrap.css">
    <style>
        .contain {
            width: 500px;
            height: 50px;
            margin: 100px auto;
        }

        .parent {
            width: 100%;
            height: 42px;
            top: 4px;
            position: relative;
        }

        .parent>input:first-of-type {
            /*输入框高度设置为40px, border占据2px，总高度为42px*/
            width: 380px;
            height: 43px;
            border: 1px solid #ccc;
            font-size: 16px;
            outline: none;
        }

        .parent>input:first-of-type:focus {
            border: 1px solid #317ef3;
            padding-left: 10px;
        }

        .parent>input:last-of-type {
            /*button按钮border并不占据外围大小，设置高度42px*/
            width: 100px;
            height: 44px;
            position: absolute;
            background: #317ef3;
            border: 1px solid #317ef3;
            color: #fff;
            font-size: 16px;
            outline: none;
        }
        .dropbtn {
            background-color: transparent;
            color: white;
            padding-left: 35px;
            padding-right: 35px;
            font-size: 16px;
            border: none;
            cursor: pointer;
        }
        .dropdown {
            position: relative;
            display: inline-block;text-align: center;
        }
        .dropdown-content {
            display: none;
            position: absolute;
            background-color: #f9f9f9;
            width: 100%;;
            box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
        }
        .dropdown-content a {
            color: black;
            padding: 12px 16px;
            text-decoration: none;
            display: block;
        }
        .dropdown-content a:hover {
            background-color: #f1f1f1
        }
        .dropdown:hover .dropdown-content {
            display: block;
        }
        .dropdown:hover .dropbtn {
            background-color: transparent;
        }
        /*导航栏样式*/
        .navbar {
            background-color: #222;
        }
        #daohang {
            list-style-type: none;
            margin: 0;
            padding: 0;
            overflow: hidden;
            background-color: transparent;
        }
        li {
            height: 40px;
            padding-left: 0;
            padding-right: 20px;
            font-size: 15px;
            float: left;
        }
        li a {
            padding: 10px;
            display: block;
            color: white;
            text-align: center;
            /*padding: 14px 16px;*/
            text-decoration: none;
        }
        /*!*鼠标移动到选项上修改背景颜色 *!*/
        li a:hover {
            background-color: #111;
        }
        .active {
            background-color: black;
        }
        .col-sm-new {
            border-radius: 15px;
            -ms-flex: 0 0 100%;
            flex: 0 0 100%;
            max-width: 100%; }
    </style>
</head>
<body>

<nav class="navbar navbar-expand-md navbar-dark fixed-top sticky-navigation">
    <a class="navbar-brand font-weight-bold" href="#">别叫我OJ</a>
    <ul id="daohang">
        <li>
            <div  id="index" align="right">
                <a style="color: white" href="index.html">首页</a>
            </div>
        </li>
        <li>
            <div id="remind" align="right">
                <a style="color: white" href="questionbank.html">题库</a>
            </div>
        </li>
        <li>
            <div id="rank" align="right">
                <a style="color: white" href="rank.html">排名</a>
            </div>
        </li>
        <li>
            <div id="userDetail" align="right">
                <a style="color: white" href="userDetail.html">个人中心</a>
            </div>
        </li>
        <li>
            <div class="active" id="ai" align="right">
                <a style="color: white" href="#">Ai聊天</a>
            </div>
        </li>
        <!--<li>
            <div style="margin-left:50px;margin-top: 5px;margin-bottom: 5px" id="manager" align="right">
                <a style="color: white" href="manager.html">管理员中心</a>
            </div>
        </li>-->
    </ul>
    <div class="collapse navbar-collapse" id="topMenu">
        <ul class="navbar-nav ml-auto" >
            <div style="margin:5px" id="javaoj">
                <span style="margin-right: 20px;color: white">欢迎！<a id="username" href="userDetail.html"></a></span>
                <a style="color: white" href="login.html" onclick="logout()"> 退出登录</a>
                <div class="dropdown">
                    <button class="dropbtn">设置</button>
                    <div class="dropdown-content">
                        <a href="updateInfo.html">修改个人信息</a>
                        <a href="updatePassword.html">修改密码</a>
                    </div>
                </div>
            </div>
        </ul>
    </div>
</nav>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    iframe{
        width: 100%;
        frameborder:0;
        border:0;
        marginwidth:0;
        marginheight:0;
        scrolling:no;
        allowtransparency:yes;
    }
    html,body{
        width: 100%;
        height: 100%;
    }

    .container{
        width: 100%;
        height: 100%;
    }
</style>
<div style="height: 35px"></div>
<div class = "container"  style="width: 100%">
    <!--        <iframe src="http://172.18.199.243:5601/app/kibana#/dashbord/Filebeat-syslog-dashboard?embed=true&_g=()" height="600" width="800"></iframe>-->
    <iframe style="overflow-x: hidden; width: 100%" src ="http://8.140.22.162:7777/spring.html"  id="info-frame"  width="100%" height="100%" ></iframe>
    <!--        <iframe src="http://www.baidu.com" frameborder="0" scrolling="no" id="info-frame" onload="setIframeHeight(this)"></iframe>-->

</div>
<!--hero section-->
<!--<section class="bg-hero">
    <div class="container">
        <div class="row vh-100">
            <div class="col-sm-new my-auto text-center">
                <h1 style="color: white">别叫我OJ</h1>
                <p style="color: white" class="lead text-capitalize my-4">
                    基于微服务实现的OJ系统
                </p>
                <a href="aboutUs.html" class="btn btn-outline-light btn-radius btn-lg">关于我们</a>
            </div>
        </div>
    </div>
</section>-->

<!--        搜索框-->
<!--<div class="contain">
    <form action="" class="parent">
        <input type="text">
        <input type="button" value="搜索">
    </form>
</div>
-->
<!--components-->
<!--<section class="my-5 pt-5">
    <div class="container">
        &lt;!&ndash; Tables  &ndash;&gt;
        <div class="row mb-5" id="tables">
            <div class="col-sm-12">
                <div class="mt-3 mb-5">
&lt;!&ndash;                            展示题库&ndash;&gt;
                    <h3>题目列表</h3>
                    <table class="table table-striped">
                        <thead>
                            <tr>
                                <th>编号</th>
                                <th>标题</th>
                                <th>难度</th>
                            </tr>
                        </thead>
                        <tbody id="problemTable">
                            <tr>
                                <td>1</td>
                                <td><a href="#">两数之和</a></td>
                                <td>简单</td>
                            </tr>
                            <tr>
                                <td>2</td>
                                <td><a href="#">两数之和</a></td>
                                <td>困难</td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
</section>-->
<p style="text-align: center">
    &copy; by <a href="aboutUs.html" target="_blank">别叫我们组</a>
</p>
<!--        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>-->
<!--<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>-->
<!--        <script src="js/app.js"></script>-->
<script>
    var userId=localStorage.getItem("userId");
    var password=localStorage.getItem("password");
    let username = document.getElementById("username");
    getUserDetail();
    function getUserDetail(){
        $.ajax({
            url:"http://localhost:8010/user/findUserById/"+userId,
            success:function (result){
                var name = result.data.username;
                //如果没有设置用户名，则显示id
                if(isEmpty(name)){
                    username.innerText=userId;
                }else{
                    username.innerText= name;
                }
                localStorage.setItem("username",name);
            }
        })
    }
    /*window.alert(userid+password);*/
    //获取问题的部分信息
    /*function getProblem(){
        $.ajax({
            url:"problem",
            type:"GET",
            success:function(data,status){
                makeProblemTable(data);
            },
        })
    }*/
    //获取用户登录信息，获取失败则返回登录页面
    function getAdmin(){
        let user={
            "id" : userId.valueOf(),
            "password" : password.valueOf(),
        };
        $.ajax({
            url:"http://192.168.47.129:8010/admin/login?id="+user.id+"&password="+user.password,
            type:"GET",
            success: function (data) {
                let msg=data.msg;
                if(msg==="登录成功") {
                    console.error("管理员yyds");
                    isAdminUser();
                }
            }
        })
    }
    //if判断是否为管理员需要更改
    //判断目前登录用户是否为管理员，是则增加跳转标签“切换到管理员界面”
    function isAdminUser(){
        // Create the new <li> element
        const newListItem = document.createElement('li');

        // Create the new <div> element
        const newDiv = document.createElement('div');
        newDiv.style.marginLeft = '20px';
        newDiv.id = 'manager';
        newDiv.align = 'right';

        // Create the new <a> element
        const newLink = document.createElement('a');
        newLink.style.color = 'white';
        newLink.href = 'manager.html';
        newLink.textContent = '管理员中心';

        // Append the <a> element to the <div> element

        newDiv.appendChild(newLink);
        // Append the <div> element to the <li> element
        newListItem.appendChild(newDiv);

        // Append the new <li> element to the existing <ul> element
        const navigationList = document.getElementById('daohang');
        navigationList.appendChild(newListItem);
        /*let div=document.querySelector("#javaoj");
        /!*if(user.isAdmin){*!/
            let a=document.createElement("a");
            a.innerHTML="切换到管理员界面";
            a.href="function.html";
            a.target="_self";
            div.appendChild(a);
        /!*}*!/*/
    }
    /*function makeProblemTable(data){
        //获取id为problemTable的元素
        let problemTable=document.querySelector("#problemTable");
        for(let problem of data){
            let tr=document.createElement("tr");
            let tdId=document.createElement("td");
            tdId.innerHTML=problem.id;
            tr.appendChild(tdId);
            let tdTitle=document.createElement("td");
            let a=document.createElement("a");
            a.innerHTML=problem.title;
            a.href="problemDetail.html?id="+problem.id;
            a.target='_blank';
            tdTitle.appendChild(a);
            tr.appendChild(tdTitle);
            let tdlevel=document.createElement("td");
            tdlevel.innerHTML=problem.level;
            tr.appendChild(tdlevel);
            problemTable.appendChild(tr);
        }
    }*/
    //获取用户登录信息，获取失败则返回登录页面
    function getUser(){
        if (userId==null){
            location.assign("login.html");
        }
    }
    function logout(){
        localStorage.clear();
    }
    function isEmpty(name) {
        if(name === '' || name.trim().length === 0){
            return true;
        }else{
            return false;
        }
    }

    /*getUser();*/

    getAdmin();
</script>
</body>
</html>
